home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: (void(far *)()) 0
- Date: 08 Feb 1996 15:54:17 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb8085417@qcd.lanl.gov>
- References: <341998718.10858110@magnet.at> <31165B9D.398E@imsisoft.com>
- <4f66c0$cn0@solutions.solon.com> <3118F813.41BF@imsisoft.com>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: Victor Bazarov's message of Wed, 07 Feb 1996 11:05:55 -0800
-
- In article <3118F813.41BF@imsisoft.com> Victor Bazarov
- <vbazarov@imsisoft.com> writes:
- <snip>
- > 0 is a special case. Zero cast to a pointer type is a null
- pointer of that
- > type. Or rather, *a constant zero* is. An integer with value zero may
- > produce different results.
-
- As I undestood, this "may produce different results":
-
- typedef void (far *pVOIDVOID)();
- int zero = 0;
- pVOIDVOID funky;
- funky = (void(far *)()) zero;
-
- than
-
- typedef void (far *pVOIDVOID)();
- pVOIDVOID funky;
- funky = (void(far *)()) 0;
-
- ?
-
- I do not know: the `far' there is a syntax error! Assuming #define far
- at the beginning of the code:
-
- The former is implementation defined behaviour: what happens
- depends on the documentation provided by the implementation. There is
- no guarantee that funky does or does not point to an actual function
- defined in the program.
-
- In the second case, the behaviour is defined by the standard. funky is
- guaranteed now to be a _valid_ pointer and it is guaranteed to compare
- unequal to the address of every function in the code.
-
- > A textual zero, cast to pointer type, points at no object; this is magic.
-
- Not only textual zeroes but a class of expressions called integral
- constant expressions that evaluate to zero. These are all constant
- expressions of integral types which can be evaluated without accessing
- any variable (not even const qualified variables), string literal or
- making a function call, and which do not involve floating point
- arithmetic or the value of addresses of objects. Examples are (1-1)
- and (sizeof("a")-2) etc.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-